package com.didispace.web;

import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 *
 * @author 程序猿DD
 * @version 1.0.0
 * @blog http://blog.didispace.com
 *
 */
@Controller
public class HelloController {

    private static final Logger LOG = LoggerFactory.getLogger(HelloController.class);
    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        return "Hello World";
    }
    @RequestMapping("/")
    public String login(ModelMap map) {
        //逻辑处理
        LOG.info("Hello World==========》  欢迎进入宝宝果园 {}",map);
        map.addAttribute("host", "http://blog.didispace.com");
        return "login";
    }

    @RequestMapping("/Account/YgUserLogin")
    @ResponseBody
    public String login(@RequestParam String UserName,@RequestParam String Pwd) {
        //逻辑处理
        LOG.info("login===>UserName={}",UserName);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("RspCode",1);
        JSONObject RspData = new JSONObject();
        RspData.put("returnUrl","http://zzipay.com/index.html");
        RspData.put("url","http://zzipay.com/index.html");
        jsonObject.put("RspData",RspData);
        jsonObject.put("RspMsg","成功");
        LOG.info("login  ==========》  欢迎进入宝宝果园 {}",jsonObject);
        return jsonObject.toString();
    }

    @RequestMapping("/MyOpt/LogOut")
    @ResponseBody
    public String LogOut() {
        //逻辑处理
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("RspCode",1);
        jsonObject.put("RspMsg","成功");
        LOG.info("LogOut  ==========》  欢迎进入宝宝果园 {}",jsonObject);
        return jsonObject.toString();
    }

}